package com.edu.spider.enity;

import java.io.Serializable;
import java.util.Date;
import java.util.UUID;

import net.sf.json.JSONObject;

import org.springframework.http.ResponseEntity;

public class SearchLog implements Serializable {
    private String id;

    private String requestContent;

    private String requestUrl;

    private String status;

    private Long resultSize;

    private Date createTime;

    private static final long serialVersionUID = 1L;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id == null ? null : id.trim();
    }

    public String getRequestContent() {
        return requestContent;
    }

    public void setRequestContent(String requestContent) {
        this.requestContent = requestContent == null ? null : requestContent.trim();
    }

    public String getRequestUrl() {
        return requestUrl;
    }

    public void setRequestUrl(String requestUrl) {
        this.requestUrl = requestUrl == null ? null : requestUrl.trim();
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status == null ? null : status.trim();
    }

    public Long getResultSize() {
        return resultSize;
    }

    public void setResultSize(Long resultSize) {
        this.resultSize = resultSize;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", requestContent=").append(requestContent);
        sb.append(", requestUrl=").append(requestUrl);
        sb.append(", status=").append(status);
        sb.append(", resultSize=").append(resultSize);
        sb.append(", createTime=").append(createTime);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }

	public static SearchLog formOthers(JSONObject json, String url,
			ResponseEntity<String> response, int status,int size) {
		SearchLog searchLog = new SearchLog();
		searchLog.setId(UUID.randomUUID().toString().replace("-", ""));
		System.out.println(json.toString());
		searchLog.setRequestContent(json.toString());
		searchLog.setRequestUrl(url);
		searchLog.setStatus(String.valueOf(status));
		searchLog.setResultSize((long) size);
		return searchLog;
	}
}